package year2020.month03456;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 支付类型
 */
public enum WeixinPayTradeTypeEnum {

    NATIVE("NATIVE", "二维码支付"),
    JSAPI("JSAPI", "公众号或小程序支付"),
    MWEB("MWEB", "H5支付"),
    APP("APP", "APP支付"),
    ;

    /**
     * 枚举值
     */
    private String code;

    private String alias;

    WeixinPayTradeTypeEnum(String code, String alias) {
        this.code = code;
        this.alias = alias;
    }

    public static List<Map> dict() {
        List<Map> list = new ArrayList<>();
        for (WeixinPayTradeTypeEnum enumElement : values()) {
            Map<String, String> map = new HashMap();
            map.put(enumElement.code, enumElement.alias);
            list.add(map);
        }
        return list;
    }
    /**
     *
     * getByCode:(根据code获取枚举值). <br/>
     *
     */
    public static WeixinPayTradeTypeEnum getByCode(String code) {
        for (WeixinPayTradeTypeEnum enumElement: values()) {
            if (enumElement.code.equalsIgnoreCase(code)) {
                return enumElement;
            }
        }
        return null;
    }

    /**
     *
     * getNameByCode:(根据code获取枚举name). <br/>
     *
     */
    public static String getAliasByCode(String code) {
        WeixinPayTradeTypeEnum target = getByCode(code);
        if (target == null) {
            return "";
        }
        return target.getAlias();
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }
}
